<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        //模拟获取  用户数据    订单数据    商品数据
        function getuser() {
            setTimeout(() => {
                let data = '用户数据';
                fns.next(data);
            }, 1000)
        }

        function getorder() {
            setTimeout(() => {
                let data = '订单数据';
                fns.next(data);
            }, 1000)
        }

        function getgoods() {
            setTimeout(() => {
                let data = '商品数据';
                fns.next(data);
            }, 1000)
        }

        function* fn() {
            let user = yield getuser();
            console.log(user);
            let order = yield getorder();
            console.log(order);
            let goods = yield getgoods();
            console.log(goods)
        }
        let fns = fn();
        fns.next();
    </script>
</body>

</html>